Object={}
Object.id=1
--Object.__newindex=Object

function Object:new()
    --self 默认传入的第一个参数
    local obj={}
    self.__index=self
    setmetatable(obj,self)
    return obj
end

function Object:GetId()
    return self.id
end

local myObj=Object:new()

print(myObj:GetId())
myObj.id=3 --在自己的表中新建一个id表项 与元表的id不同了
print(Object.id)
print(myObj:GetId())

local myObj2=myObj:new()
print(myObj2.id)

print("__________________________________________________________________")
function Object:subClass(className)
    _G[className]={}
    local obj=_G[className]
    self.__index=self
    setmetatable(obj,self)
    return obj
end

Object:subClass("GameObject")
local myGameObj=GameObject:new()
myGameObj.id=5
print(myGameObj:GetId())

--[[test={1,a="2"}
test.b=321
print(test["b"])


for key, value in pairs(_G) do
    print(key,value)
end

meta={}
meta.__newindex={}
meta.__index=meta.__newindex

hyu={}
setmetatable(hyu,meta)

hyu.i=456
hyu.i=897

print(hyu.i)
print(meta.__newindex.i)
]]

print("__________________________________________________________________")
myTable = {age = 1}
local myTable2 = myTable
myTable2.age = 2
print(myTable.age)